﻿using GameProject.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace GameProject.Repository
{
	public class AppRepository : IAppRepository
	{
		private AppDataContext context = new AppDataContext();

		public IEnumerable<UserProfile> GetUsers()
		{
			return context.UserProfiles;
		}

		public IEnumerable<GameInstance> GetGames()
		{
			return context.GameInstances.Include(x => x.GameType).Include("PieceSnakes").Include("PieceSnakes.User").Include("Grid.Cells");
		}

		public IEnumerable<GameType> GetGameTypes()
		{
			return context.GameTypes;
		}

		public void AddGameInstance(GameInstance game)
		{
			context.GameInstances.Add(game);
		}
		public void Save()
		{
			context.SaveChanges();
		}

		public void AddGameType(GameType gameType)
		{
			context.GameTypes.Add(gameType);
		}
	}
}